﻿@using Smartstore.Web.Models.Cart;

@model ShoppingCartModel.DiscountBoxModel

@{ 
	if (!Model.Display)
	{
		return;
	}

	var isExpanded = Model.Message.HasValue() || Model.CurrentCode.HasValue();
}

<div class="cart-action cart-action-coupon">
    <h5 class="cart-action-title" attr-class='(!isExpanded, "collapsed")' data-toggle="collapse" data-target="#cart-action-coupon-body" aria-controls="cart-action-coupon-body" aria-expanded="@isExpanded.ToString().ToLower()">
		@T("ShoppingCart.DiscountCouponCode")
	</h5>
        
    <div class="cart-action-body collapse" id="cart-action-coupon-body" aria-expanded="@isExpanded.ToString().ToLower()" attr-class='(isExpanded, "show")'>
        @if (Model.Message.HasValue())
        {
            <div class="alert d-flex justify-content-between alert-@(Model.IsWarning ? "danger" : "success") fade show">
                <span>@Model.Message</span>
                <button type="button" class="close" data-dismiss="alert">&times;</button>
            </div>
        }

        <div class="coupon-code form-group">
            <div class="input-group" attr-class='(Model.CurrentCode.HasValue(), "has-success")'>
                <input name="discountcouponcode" type="text" class="form-control form-control-success discount-coupon-code" value="@Model.CurrentCode" placeholder="@T("ShoppingCart.DiscountCouponCode.Tooltip")" />
                <span class="input-group-btn input-group-append">
                    @if (Model.CurrentCode.HasValue())
                    {
                        <a href="#"
                           data-href='@Url.Action("RemoveDiscountCoupon", "ShoppingCart")'
                           class="btn btn-danger remove-discount-button ajax-action-link">
                            <span>@T("Common.Remove")</span>
                        </a>
                    }
                    else
                    {
                        <button type="submit"
                                class="btn btn-primary apply-discount-coupon-code-button"
                                title="@T("ShoppingCart.DiscountCouponCode.Button")"
                                name="applydiscountcouponcode"
                                value="applydiscountcouponcode">
                            <i class="fa fa-check"></i>
                            <span>@T("ShoppingCart.DiscountCouponCode.Button")</span>
                        </button>
                    }
                </span>
            </div>
        </div>
    </div>
</div>